package cn.tedu.yl.recharge.service.impl;

import cn.tedu.yl.recharge.mapper.RechargeMapper;
import cn.tedu.yl.recharge.pojo.dto.RechargeQuery;
import cn.tedu.yl.recharge.pojo.dto.RechargeSaveParam;
import cn.tedu.yl.recharge.pojo.entity.Recharge;
import cn.tedu.yl.recharge.pojo.vo.RechargeVO;
import cn.tedu.yl.recharge.service.RechargeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RechargeServiceImpl implements RechargeService {
    @Autowired
    private RechargeMapper rechargeMapper;
    @Override
    public void save(RechargeSaveParam rechargeSaveParam) {
        Recharge recharge=new Recharge();
        BeanUtils.copyProperties(rechargeSaveParam,recharge);
        if (recharge.getId()==null){

            rechargeMapper.insertRecharge(recharge);
        }
        else {
            rechargeMapper.updateRecharge(recharge);
        }
    }

    @Override
    public List<RechargeVO> select(RechargeQuery rechargeQuery) {
       return rechargeMapper.selectRecharge(rechargeQuery);
    }
}
